#include<stdio.h>
int main()
{
    double h,m=0;
    scanf("%lf:%lf",&h,&m);
    double c=h*30.0+m*0.5;
    double d=m*6.0;
    //printf("%lf%lf",c,d);
    double e=c-d;
    if(e<0)e=0.0-e;
    else if(e>180&&e<360)e=360.0-e;
    else if(e>=360)e=720.0-e;
    printf("%.3lf",e);
    return 0;
}
